
import LeftTreeDom from '../components/leftTreeDom/index.js'
import RightTableDom from '../components/rightTableDom/index.js'
import {createPage} from 'nc-lightapp-front';
import {render} from '../../../../hrpub/common/frame';
import {base} from 'nc-lightapp-front';
import MainAction from '../actions/main.js';
import BtnAction from '../actions/btn.js'
import './index.less'
import TempAction from '../actions/temp.js';
import { getAppPageConfig } from 'src/hrpub/common/utils/utils';


let { NCRow, NCCol} = base;

const MainPage = render({
    actions: {
        MainAct : MainAction,
        btnAct: BtnAction,
        tempAction: TempAction
    }
})(({props, action, state}) => {
    const {main,modal,form,DragWidthCom} = props
    const {createModal} = modal
    const {createForm} = form


    const Modalcontext =(that)=> {
        return(
            <React.Fragment>
                {createForm('handitemcard',{
                    onAfterEvent: action.tempAction.onAfterFormEvent
                })}
            </React.Fragment>
        )  
    }

    const dom = JSON.stringify(main.json) !=='{}'?
        <div className="tree-table">
            <DragWidthCom
                leftDom ={
                    <LeftTreeDom
                        {...props}
                    />
                }
                rightDom ={
                    <RightTableDom
                        {...props}
                    />  
                }
                defLeftWid="15%"
            />
             {
                 createModal('addModal',{
                    title: main.modaltitle,
                    content: Modalcontext.call(this,this),
                    beSureBtnClick: action.btnAct.beSureBtnClick, //点击确定按钮事件
                    cancelBtnClick:  action.btnAct.cancelBtnClick, //取消按钮事件回调
                    closeModalEve:  action.btnAct.cancelBtnClick, //关闭按钮事件回调
                    size:'lg', //  模态框大小 sm/lg/xlg/xxlg
                    leftBtnName: main.json["gx6008-000035"],
                    hotKeyboard: true//快捷键的配置项，传true支持快捷键功能
                 })
             }
        </div> : null
    return(
        <React.Fragment>
            {dom}
        </React.Fragment>
    )
})
export default createPage({
    billinfo:{
        billtype: 'grid', 
        pagecode: getAppPageConfig().appcode, 
        bodycode: 'handitemgrid'
    }
})(MainPage);